package com.solocredit.finance.mvp.proxy.fm;

import android.content.Context;
import android.os.Bundle;
import android.view.View;

import com.solocredit.finance.mvp.presenter.MvpPresenter;
import com.solocredit.finance.mvp.proxy.MvpDelegateCallbackProxy;
import com.solocredit.finance.mvp.view.MvpView;

/**
 * MullaFlow
 *
 * @Author wwdeng
 * @CreateTime: 2024/7/24 10:36
 * @Annotation：具体的目标接口实现类
 */
public class FmMvpDelegateImpl<V extends MvpView, P extends MvpPresenter<V>> implements FmMvpDelegate<V, P> {

    private MvpDelegateCallbackProxy<V, P> proxy;
    // 具体的目标接口实现类，需要持有创建Mvp实例
    private FmMvpDelegateCallback<V, P> delegateCallback;

    public FmMvpDelegateImpl(
            FmMvpDelegateCallback<V, P> delegateCallback) {
        if (delegateCallback == null) {
            throw new NullPointerException("delegateCallback is not null!");
        }
        this.delegateCallback = delegateCallback;
    }

    private MvpDelegateCallbackProxy<V, P> getDelegateProxy() {
        if (this.proxy == null) {
            this.proxy = new MvpDelegateCallbackProxy<V, P>(delegateCallback);
        }
        return this.proxy;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {

    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {

    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        getDelegateProxy().createPresenter();
        getDelegateProxy().attachView();
    }

    @Override
    public void onStart() {

    }

    @Override
    public void onPause() {

    }

    @Override
    public void onResume() {

    }

    @Override
    public void onStop() {

    }

    @Override
    public void onDestroyView() {
        getDelegateProxy().detachView();
    }

    @Override
    public void onDestroy() {

    }

    @Override
    public void onSaveInstanceState(Bundle outState) {

    }

    @Override
    public void onAttach(Context context) {

    }

    @Override
    public void onDetach() {

    }
}
